
var http = require('http')


var fs = require('fs')

var app = http.createServer(function(req,res){
    //1. 获取地址栏的路径
    // console.log(req.url); // /b.html
    // console.log(req.pathname)
    
    var filePath = '.'+ req.url
    console.log(filePath)

    fs.readFile(filePath,function(err, data){
        if(err){
            res.write('page not found')
            res.end()
        }else{
            res.write(data)
            res.end()
        }
       
    })
    
})

app.listen(8080)